package com.benbi.shequapi.service.impl;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.benbi.shequapi.bean.*;
import com.benbi.shequapi.mapper.*;
import com.benbi.shequapi.service.ClockinService;
import com.benbi.shequapi.utils.Result;
import com.benbi.shequapi.utils.ResultData;
import org.springframework.dao.DuplicateKeyException;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

@Service
public class ClockinImpl implements ClockinService {
    @Resource
    ClockinMapper clockinMapper;

    @Override
    public Result getClockinByWpid(int w_pid) {
        Clockin p = clockinMapper.selectClockinByWpid(w_pid);
        if (p == null) {return new Result(1, "不存在该打卡");}
        return new ResultData(p);
    }

    @Override
    public Result newClockin(int w_pid,String form_addr,String business,String remark) {
        Date d = new Date();
        Clockin clockin = new Clockin(w_pid,form_addr,business,d,remark);
        int p = clockinMapper.uploadClockin(clockin);
        return new Result(0, "成功");
    }



}
